using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Web.Security;
using Microsoft.ApplicationBlocks.Data;

namespace Customs.Components.KDT
{
    public class DoanhNghiep
    {
		public static bool Login(string MaDoanhNghiep, string MatKhau)
		{
            string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString_KDT"].ConnectionString;
            string query = "SELECT * FROM DUser WHERE AccountName = @MaDoanhNghiep";
			SqlParameter[] parameters = new SqlParameter[1];

			parameters[0] = new SqlParameter("@MaDoanhNghiep", SqlDbType.VarChar, 14);
            parameters[0].Value = MaDoanhNghiep;

			SqlDataReader reader = SqlHelper.ExecuteReader(connectionString, CommandType.Text, query, parameters);
			if (reader.Read())
			{
                //string pass_salt = string.Concat(MatKhau, reader["Salt"].ToString());
                //string finalPass = FormsAuthentication.HashPasswordForStoringInConfigFile(pass_salt, "SHA1");
                if (MatKhau.Equals(reader["Password"].ToString()))
				{
					return true;
				}
			}
			return false;
		}
    }
}
